[#include "single/layout/layout02/layout.ftl"/]
[@htmlHead]
<link href="${jpath}/assets/public/plugins/jqGrid/css/ui.jqgrid-bootstrap.css" rel="stylesheet" type="text/css"/>
[/@htmlHead]

[@htmlBody]
<div class="row">
    <div class="col-xs-12">
        <ul class="nav nav-tabs ">
            <li>
                <a href="${base}/employee/view/index">
                    员工列表
                </a>
            </li>
            <li class="active">
                <a href="javascript:void(0)">
                    员工授权
                </a>
            </li>
        </ul>
    </div>
</div>
<div class="row">
    <form class="form-horizontal " id="search-form">

        <div class="form-group">

            <label class="col-xs-12 col-sm-1 control-label">名称：</label>

            <div class="col-xs-12 col-sm-2">
                <input type="text" name="name" class="form-control "/>
            </div>
            <label class="col-xs-12 col-sm-1 control-label">英文名称：</label>

            <div class="col-xs-12 col-sm-2">
                <input type="text" name="ename" class="form-control "/>
            </div>
            <div class="col-xs-12 col-sm-3">
                <button class=" btn btn-info btn-sm btn-sm " type="button" onclick="doSearch()"><i
                        class="ice-icon fa fa-search"></i>查找
                </button>
            </div>
        </div>
    </form>
</div>
<div id="indexAlert" class="hide" style="min-width:400px"></div>
<div class="row">
    <input name="accountId" id="accountId" value="${id}" type="hidden"/>
    <input id="roleIds" value="${roleIds}" type="hidden"/>
    <div class="col-xs-12 ">
        <table id="jqGrid" class="grid_auto" grid_ref=""></table>
        <div id="jqGridPager"></div>
    </div>
</div>

<div class="form-group mrg-t-md">

    <div class=" col-xs-12 " align="center">
        <input type="button" class="btn btn-info btn-sm" value="保存" onclick="doSave()"/>
        <input type="button" onclick="tools.goto('${base}/account/view/index')" class="btn btn-sm" value="返回"/>
    </div>
</div>

[/@htmlBody]

[@htmlFoot]
<script type="text/javascript" src="${jpath}/assets/public/plugins/jqGrid/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/plugins/dialog/bootbox.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/plugins/jqGrid/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/plugins/jqGrid/jqGrid-extends.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

       loadData();
        page_handlers.resize_handler=function(){
            jqGrids.auto_size();
        };
    });
    function doSave() {
//        var ids=$('#jqGrid').jqGrid('getGridParam','selarrrow');//获得所有被选中的id
//        var url = base + "/account/sk/authorization/insert";
//        var accountId = $("#accountId").val();
//        var roleIds = $("#roleIds").val().split(",");//...
//        $.post(url, {ids:ids,roleIds:roleIds, accountId: accountId}, function (data) {
//            $.messager.alert0({selector: "#indexAlert", type: data.code, html: data.message});
//            if (data && data.code == 'SUCCESS') {
//                tools.goto(base + "/employee/view/index", 500);
//            }
//        })
    }

    function loadData(){
        var id=$("#accountId").val();
        $("#jqGrid").jqGrid($.extend(jqGrids.defaults,{
            url:base+ '/account/view/authorization/list?accountId='+id,
            colNames:[ '中文名称','英文名称','描述', '创建时间'],
            colModel: [
                {name:'name',index:'name',width:'90'},
                {name:'enname',index:'enname',width:'90'},
                {name:'description',index:'description',width:'90'},
                {name:'createTime',index:'createTime',formatter:tools.formatDate,width:'140'}
            ]
        }));
    }

    /**查询*/
    function doSearch(){
        var name=$("input[name=name]").val();
        var ename=$("input[name=ename]").val();
        $("#jqGrid").jqGrid('setGridParam',{
            datatype:'json',
            postData:{'roleName':name,'ename':ename}, //发送数据
            page:0
        }).trigger("reloadGrid"); //重新载入
    }

</script>

[/@htmlFoot]